package com.qdsg.modulesihealsdk.ecgSingle;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.qdsg.modulesihealsdk.utils.SihealSdkConstant;


/**
 * @Description
 * @Author WuJianFeng
 * @Date 2023/2/1 14:46
 */
public class ECGBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action.equals(SihealSdkConstant.BLU_ACTION_STATE_CHANGE)) {
//            tvStatus.setVisibility(View.VISIBLE);
            String state = intent.getExtras().getString("arg1");
            if (state.equals("OPENING")) {
//                tvStatus.setText(R.string.connect_opening);
            } else if (state.equals("OPENINGFILE")) {
//                tvStatus.setText(R.string.connect_openfail);
//                imgProgress.clearAnimation();
//                imgProgress.setImageResource(R.drawable.bluecon_0);
//                dismiss(5);
            } else if (state.equals("DISCOVERYING")) {
//                tvStatus.setText(R.string.connect_startseach);
            } else if (state.equals("CONNECTING")) {
                // tvStatus.setText(R.string.connect_startconnect);
//                tvStatus.setText(R.string.connect_startconnect);
            } else if (state.equals("CONNECTED")) {
//                tvStatus.setText(R.string.connect_success);
//                imgProgress.clearAnimation();
//                imgProgress.setImageResource(R.drawable.bluecon_1);
//                dismiss(1);
            } else if (state.equals("CONNECTFILE")
                    || state.equals("DISCOVERYED")) {

            }
        } else if (action.equals(SihealSdkConstant.ACTION_BLUETOOH_OFF)) {
//            tvStatus.setText(R.string.connect_close);
//            imgProgress.clearAnimation();
//            imgProgress.setImageResource(R.drawable.bluecon_0);
            context.sendBroadcast(new Intent(
                    SihealSdkConstant.BLU_ACTION_STOPDISCOVERY));
            context.sendBroadcast(new Intent(SihealSdkConstant.BLU_ACTION_DISCONNECT));
        }
    }
}
